﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace SIS.DataAccess
{
	/// <summary>
	/// Author: hieunv
	/// </summary>
	class Department : DataTable
	{
		public const string DEPARTMENT_NAME = "dept_name";
		public const string BUILDING = "building";
		public const string BUDGET = "budget";

		public Department()
			: base("Department")
		{
			var departmentName = new DataColumn(DEPARTMENT_NAME, typeof(string));
			departmentName.AllowDBNull = false;

			var building = new DataColumn(BUILDING, typeof(string));
			building.AllowDBNull = true;

			var budget = new DataColumn(BUDGET, typeof(int));
			budget.AllowDBNull = true;

			this.Columns.Add(departmentName);
			this.Columns.Add(building);
			this.Columns.Add(budget);

			this.PrimaryKey = new DataColumn[] { departmentName };
		}

		public static DataTable GetDepartmentName()
		{
			var departmentNames = new DataTable();
			DataServices.ExecuteQuery(QueryType.SELECT, CommandType.Text, "SELECT dept_name FROM department", null, departmentNames);
			return departmentNames;
		}
	}
}
